<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['education']) && (($_SESSION['education']&1<<2) == 0))) {
	$this->_redirect(HOST_BACKEND);
}
$arrParams		= $objRequest->getParams();
$strRefer		= isset($arrParams['prefer']) ?  $arrParams['prefer'] : HOST_BACKEND . 'education/cmt';
$intCmtId		= isset($arrParams['pecmtid']) ?  $arrParams['pecmtid'] : 0;
$strTitle		= isset($arrParams['ptitle']) ?  Ecore_Function::stripTags($arrParams['ptitle'],-2) : '';
$strContent		= isset($arrParams['pcontent']) ?  Ecore_Function::stripTags($arrParams['pcontent'],-3) : '';
$intError		= 0;
if($strTitle == '') {
	$intError	= 10;
}elseif(strlen($strTitle) < 5) {
	$intError	= 11;
}elseif($strContent == '') {
	$intError	= 12;
}elseif(strlen($strContent) < 20) {
	$intError	= 13;
}

if($intError == 0) {	
	if(isset($_SESSION['ecmtpost'])) unset($_SESSION['ecmtpost']);
	if(isset($_SESSION['ecmterr'])) unset($_SESSION['ecmterr']);	
	$objEducation 	= new Education();
	$intError		= $objEducation->updateCmt($AppUI->id, $intCmtId, $strTitle, $strContent);
	if($intError == 0) {				
		Ecore_Function::setMsg($arrMessage[7]);
		$this->_redirect($strRefer);
	}
}
if($intError > 0) {
	$_SESSION['ecmtpost']	= $objRequest->getParams();
	$_SESSION['ecmterr']	= $arrError[$intError];
	$this->_redirect(HOST_BACKEND . 'education/cmte?ecmtid='.$intCmtId);
}